package com.powernode.lambda.lambda;

import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * 方法引用之new  类名::new
 */
public class Lambda06 {
    static class Dog{
        private String name;
        private Integer age;

        public Dog() {
        }

        public Dog(String name) {
            this.name = name;
            this.age = 2;
        }

        public Dog(String name, Integer age) {
            this.name = name;
            this.age = age;
        }

        @Override
        public String toString() {
            return "Dog{" +
                    "name='" + name + '\'' +
                    ", age=" + age +
                    '}';
        }
    }
    public static void main(String[] args) {
        Supplier<Dog> supplier = Dog::new;//对应无参构造
        Function<String,Dog> function = Dog::new;//对应一个参数的构造方法
        BiFunction<String,Integer,Dog> biFunction = Dog::new;//对应两个参数的构造方法
        System.out.println(supplier.get());
        System.out.println(function.apply("小花"));
        System.out.println(biFunction.apply("大黄", 4));
    }


}
